package com.leoman.utils;

import java.util.List;
import java.util.Random;

/**
 * Created by Administrator on 2016/3/16.
 */
public class KdxgUtils {

    private static final double PROBABILITY_GET = 0.5;

    public static boolean isGet() {
        if (Math.random() < PROBABILITY_GET) {
            return true;
        } else {
            return false;
        }
    }

    public static String getFileName(String proId, String salemanId) {
        StringBuffer buffer = new StringBuffer("");
        buffer.append("PRODUCTID").append(proId).append("SALEMANID").append(salemanId).append(".jpg");
        return buffer.toString();
    }

    public static Long getCouponId(List<Long> ids) {
        return ids.get(getRandomInt(ids.size()));
    }

    /**
     * 获得一个[0,max)之间的整数。
     *
     * @param max
     * @return
     */
    public static int getRandomInt(int max) {
        Random random = new Random();
        return Math.abs(random.nextInt()) % max;
    }
}
